﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.CMS.Common.Utility;
using Runda.CMS.Order.Entity;
using Runda.CMS.Order.Repository;

namespace Runda.CMS.Portal.OrderManagement
{
    public partial class ShippingRequestList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList(1);
            }
        }

        private void BindList(int pageindex)
        {
            ShippingRequestRepository shippingRequestRepository = new ShippingRequestRepository();
            int recordCount = 0;
            var list = shippingRequestRepository.findShippingRequestLists(ddlStatus.SelectedValue.ToString(),txtCustomerName.Text.Trim(), txtInventoryName.Text.Trim(), txtRequestShippingNum.Text.Trim(), txtSendBillNum.Text.Trim(), txtOrderNum.Text.Trim(), AspNetPager1.PageSize, pageindex, out recordCount);

            RepeaterOrders.DataSource = list;
            RepeaterOrders.DataBind();
            AspNetPager1.RecordCount = recordCount;
            
        }

        protected void btnSearch_Click(object sender, EventArgs e){
            BindList(1);
        }

        protected void RepeaterOrders_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "refersh")
            {
                BindList(1);
            }
            if (e.CommandName == "delete")
            {

            }
        }
        protected void lnkbtnDelete_Click(object sender, EventArgs e)
        {

        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {

            BindList(AspNetPager1.CurrentPageIndex);
        }

        protected void RepeaterOrders_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                //Label deliverNum = e.Item.FindControl("deliverNum") as Label;
                //Label receiveDate = e.Item.FindControl("receiveDate") as Label;
                //Label cStatus = e.Item.FindControl("cStatus") as Label;

                //if (receiveDate.Text != "")
                //{
                //    cStatus.Text = "已签收";
                //}
                //else
                //{
                //    if (deliverNum.Text != "")
                //    {
                //        cStatus.Text = "快递中";
                //    }
                //}
            }
        } 
    }
}
